package com.example.controller.interceptor;

import com.example.controller.results.Result;
import com.example.system.exception.BusinessException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author Li Cheng
 * @Date 2021/6/28 22:00
 * @Version 1.0
 */
@Component
@ControllerAdvice
public class ProjectExceptionAdvice {


    @ExceptionHandler(BusinessException.class)
    @ResponseBody
     public Result doBusinessException(BusinessException e){
         return new Result(e.getCode(),e.getMessage());
     }


}
